package tungsten.base;

import tungsten.base.event.EventBus;
import tungsten.base.thread.ThreadPool;

import java.util.concurrent.SynchronousQueue;
import java.util.concurrent.TimeUnit;

/**
 * Created by Lv on 2016/6/24.
 */
public class BaseApp
{
    public BaseApp()
    {

    }

    final public void start()
    {
        initConfig();
        initThread();
        Runtime.getRuntime().addShutdownHook(new Thread(() -> {
            onExit();
        }));
    }

    protected void initThread()
    {
        ThreadPool.initThread(EventBus.EVENT_THREAD,0,Integer.MAX_VALUE,60L, TimeUnit.SECONDS, new SynchronousQueue<>());
    }

    protected void initConfig()
    {

    }

    protected void onExit()
    {

    }

    protected int getSchedulePoolSize()
    {
        return 2;
    }
}
